import { getToken, setToken, delToken } from '@/utils/storage'
// import router from '@/router'
const state = {
  token: getToken(),
  refreshToken: localStorage.getItem('refresh-token')
}

const mutations = {
  SET_TOKEN (state, token) {
    state.token = token.current_token
    setToken(token.current_token)
    if (token.refresh_token) {
      state.refreshToken = token.refresh_token
      localStorage.setItem('refresh-token', token.refresh_token)
    }
  },
  REMOVE_TOKEN (state) {
    state.token = ''
    state.refreshToken = ''
    localStorage.removeItem('refresh-token')
    delToken()
  }
}

const actions = {

}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
